<?xml version="1.0" encoding="UTF-8"?>
<!--
To change this template, choose Tools | Templates
and open the template in the editor.
-->
<!DOCTYPE html>
<!--author: AGolubinskyy -->
<html xmlns="http://www.w3.org/1999/xhtml" 
      xmlns:f="http://java.sun.com/jsf/core" 
      xmlns:p="http://primefaces.prime.com.tr/ui" 
      xmlns:ui="http://java.sun.com/jsf/facelets" 
      xmlns:h="http://java.sun.com/jsf/html">
    <h:head>
        <title>TODO supply a title</title>
    </h:head>
    <h:body>
        <ui:component>
            <p:messages globalOnly="true"/>
            <h:form>
                <p:messages globalOnly="true"/>
                <h:panelGrid columns="3" columnClasses="utilInfoColumn, utilControlsColumn, utilErrorColumn">
                    <h:outputText value="Add category" />
                    <p:inputText value="#{ub.categoryName}" required="true" id="catname"
                                 requiredMessage="Please enter category name"/>
                    <p:message for="catname"/>
                    <h:outputText value=""/>
                    <h:commandButton value="Add" action="#{ub.addCategory}">
                        <f:ajax execute="@this catname" render="@form"/>
                    </h:commandButton>
                    <h:outputText value=""/>
                    <h:outputText value="Add to category" />
                    <h:selectOneMenu value="#{ub.categoryID}" id="catid">
                        <f:selectItems value="#{ub.categories}"/>
                    </h:selectOneMenu>
                    <h:outputText value=""/>
                    <h:outputText value="Product"/>
                    <p:inputText value="#{ub.productName}" required="true" id="prodname"
                                 requiredMessage="Please enter product name"/>
                    <p:message for="prodname"/>
                    <h:outputText value="Common product"/> 
                    <h:selectBooleanCheckbox value="#{ub.productCommon}" id="prodcommon"/>
                    <h:outputText value=""/>
                    <h:outputText value=""/>
                    <h:commandButton value="Add" action="#{ub.addProduct}">
                        <f:ajax execute="@this catid prodcommon prodname" render="@form"/>
                    </h:commandButton>
                    <h:outputText value=""/>
                    <h:outputText value="Rename category" />
                    <h:selectOneMenu value="#{ub.categoryID}" id="catidrename">
                        <f:selectItems value="#{ub.categories}"/>
                    </h:selectOneMenu>
                    <h:outputText value=""/>
                    <h:outputText value="New name"/>
                    <p:inputText value="#{ub.categoryName}" required="true" id="catrename"
                                 requiredMessage="Please enter category name"/>
                    <p:message for="catrename"/>
                    <h:outputText value=""/>
                    <h:commandButton value="Rename" action="#{ub.editCategory}">
                        <f:ajax execute="@this catidrename catrename" render="@form"/>
                    </h:commandButton>
                    <h:outputText value=""/>
                    <h:outputText value="Rename product"/>
                    <h:selectOneMenu value="#{ub.productID}" id="prodidrename">
                        <f:selectItems value="#{ub.products}"/>
                    </h:selectOneMenu>
                    <h:outputText value=""/>
                    <h:outputText value="New name"/>
                    <p:inputText value="#{ub.productName}" required="true" id="prodrename"
                                 requiredMessage="Please enter product name"/>
                    <p:message for="prodrename"/>
                    <h:outputText value="Common product"/> 
                    <h:selectBooleanCheckbox value="#{ub.productCommon}" id="prodcommonrename"/>
                    <h:outputText value=""/>
                    <h:outputText value=""/>
                    <h:commandButton value="Rename" action="#{ub.editProduct}">
                        <f:ajax execute="@this prodidrename prodcommonrename prodrename" render="@form"/>
                    </h:commandButton>
                    <h:outputText value=""/>
                    <h:outputText value="Delete product"/>
                    <h:selectOneMenu value="#{ub.productID}" id="prodiddelete">
                        <f:selectItems value="#{ub.products}"/>
                    </h:selectOneMenu>
                    <h:outputText value=""/>
                    <h:outputText value=""/>
                    <h:commandButton value="Delete" action="#{ub.deleteProduct}">
                        <f:ajax execute="@this prodiddelete" render="@form"/>
                    </h:commandButton>
                    <h:outputText value=""/>
                    <h:outputText value="Delete category"/>
                    <h:selectOneMenu value="#{ub.categoryID}" id="catiddelete">
                        <f:selectItems value="#{ub.categories}"/>
                    </h:selectOneMenu>
                    <h:outputText value=""/>
                    <h:outputText value=""/>
                    <h:commandButton value="Delete" action="#{ub.deleteCategory}">
                        <f:ajax execute="@this catiddelete" render="@form"/>
                    </h:commandButton>
                </h:panelGrid>
            </h:form>
        </ui:component>
    </h:body>
</html>
